﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <title>登录</title>
    <meta http-equiv='content-type' content='text/html;charset=utf-8'/>
    <script type='text/javascript' src='assets/js/jquery-1.8.2.min.js'></script>
    <script type='text/javascript'>
        function login() {
            const emailValue = $(" input[ name='email' ] ").val();
            const password = $(" input[ name='password' ] ").val();
            const param = {'email':emailValue,'password':password};
            //alert(JSON.stringify(param));
            $.ajax({
                type:"post",
                url:'/api/user/login',
                dataType: 'json',
                contentType:"application/json",
                cache : false,
                data: JSON.stringify(param),
            }).done(function(result){
                alert(JSON.stringify(result));
                if(result.code === 200){
                    document.cookie = "sessionId=" + result.message;
                    window.location.href='welcome.html?email=' + emailValue
                }
                else {
                    $('#error').html(result.message);
                }
            }).fail(function(){
                alert('fail');
            });
        }
    </script>
    <style type='text/css'>
        #code {
            font-family: Arial, 宋体;
            font-style: italic;
            color: blue;
            size: 12px;
            border: 0;
            padding: 2px 3px;
            letter-spacing: 8px;
            font-weight: bolder;
        }
    </style>
</head>

<body>
<table border=0>
    <tr>
        <th width=200 height=30></th>
        <th><img src="images/login.jpg"/></th>
    </tr>
</table>
<table border=0>
    <tr>
        <th width=700 height=400></th>
        <th>
            <table border=0 height=195>
                <tr>
                    <th height=65><font size='4'>邮 箱</font></th>
                    <th colspan="2"><input type="text" style="height:40px" placeholder="请输入用户名" size=40
                                           name="email"></th>
                </tr>
                <tr>
                    <th height=65><font size='4'>密 码</font></th>
                    <th colspan="2"><input type="password" style="height:40px" placeholder="密码长度为6~18字符" size=40
                                           id="password" name="password">
                    </th>
                </tr>
                <tr>
                    <th></th>
                    <th height=65><button onclick="login()">登录</button></th>
                    <th><a href="register.html">注册新账号</a></th>
                </tr>
                <tr>
                    <th colspan="3" id="error"></th>
                </tr>
            </table>
        </th>
    </tr>
</table>
<table>
    <tr>
        <th bgcolor='f9f8ed' height=200 width=2000>
            <p>📧联系邮箱：xxxxxxxx@qq.com</p>
            <p>联系地址：xxxx</p>
            <p>📞联系电话：xxxxxxxx</p>
        </th>
    </tr>
</table>
</body>
</body>
</html>
